package com.lesso.lll.sunflower.device.controller;

import com.lesso.lll.sunflower.device.entity.AttendanceDevice;
import com.lesso.lll.sunflower.device.service.AttendanceDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 考勤设备控制器
 */
@RestController
@RequestMapping("/api/device")
@Api(tags = "AttendanceDeviceController", description = "考勤设备管理")
public class AttendanceDeviceController {

    @Autowired
    private AttendanceDeviceService deviceService;

    @ApiOperation("新增设备")
    @PostMapping("/add")
    public CommonResult<Long> addDevice(@RequestBody AttendanceDevice device) {
        Long deviceId = deviceService.addDevice(device);
        return CommonResult.success(deviceId);
    }

    @ApiOperation("修改设备信息")
    @PostMapping("/update")
    public CommonResult<Boolean> updateDevice(@RequestBody AttendanceDevice device) {
        boolean result = deviceService.updateDevice(device);
        return CommonResult.success(result);
    }

    @ApiOperation("删除设备")
    @PostMapping("/delete/{deviceId}")
    public CommonResult<Boolean> deleteDevice(@PathVariable Long deviceId) {
        boolean result = deviceService.deleteDevice(deviceId);
        return CommonResult.success(result);
    }
}    